<html>
<head>
	<title>Paste from Word</title>
	<script type="text/javascript" src="../prototype.js" ></script>
</head>
<body>
	<form>
	<table class="formTable" width="100%">
		<tr>
		<td>
			<iframe id="Input" style="width:500px; height:400px;" src="blank.html"></iframe>			
		</td>
		</tr>
	</table>
	
	<input type="submit" id="PasteButton" value="Paste into Editor"  /> 
	</form>
	

<script type="text/javascript">	

Event.observe(window,'load',init);
Event.observe('PasteButton','click',submitLink);
Event.observe(document.getElementsByTagName('form')[0],'submit',submitLink);

var ftb;

function init() {

	if (window.opener)
		refresh = window.opener.Refresh;
	else
		refresh = window.parent.Refresh;
	
	ftb = refresh.Web.CurrentFreeTextBox;
	if (ftb == null) ftb = refresh.Web.FreeTextBoxList[0];
		
	// set language 
	refresh.Web.Localization.updateLanguageElements(document, ftb.settings.language);
	
	
	// setup "editor"	
	var editor = $('Input');
	var doc = editor.contentWindow.document;
	doc.designMode = 'on';
	doc.open();
	doc.write('<html><body></body></html>');
	doc.close();
	doc.contentEditable = true;	
	try {
		doc.focus();
	} catch (e) {}
}
function submitLink(event) {
	Event.stop(event);

	var editor = $('Input');
	var doc = editor.contentWindow.document;
	
	// clean up Word HTML
	doc.body.innerHTML = window.parent.Refresh.Web.WordClean.cleanText(doc.body.innerHTML);
	
	var html = window.parent.Refresh.Web.HtmlCleaner.validateNode(doc.body, false, true);
		
	ftb.insertHtml(html);
	
	refresh.Web.ModalWindow.hide();
	window.close();
}
</script>
</body>
</html>